//
//  WBStatusCell.swift
//  WeiBoApp
//
//  Created by James on 2017/7/16.
//  Copyright © 2017年 James. All rights reserved.
//

import UIKit

class WBStatusCell: UITableViewCell {
    
    
    /// 微博视图模型
    var viewModel:WBStatusViewModel?{
        didSet{
            iconView.hzj_setImage(urlString: (viewModel?.status.user?.profile_image_url)!, placeholdImage: #imageLiteral(resourceName: "avatar_default_small"),isAvatar: true)
            
            statusLabel.text = viewModel?.status.text
            nameLabel.text = viewModel?.status.user?.screen_name
            
            //设置会员图标
            vipImageView.image = viewModel?.memberIcon
            
            vipIconImageView.image = viewModel?.vipIcon
            
            bottomToolBar.viewModel = viewModel
            
            picturesView.heightCons.constant = viewModel?.pictureViewSize.height ?? 0
            
            
            if viewModel?.status.pic_urls?.count ?? 0 > 4 {
                var arr = viewModel?.status.pic_urls ?? []
                arr.removeSubrange((arr.startIndex+4) ..< arr.endIndex)
                
            }else{
                picturesView.urls = viewModel?.status.pic_urls
            }
            
        }
    }
    
    /// 头像
    @IBOutlet weak var iconView: UIImageView!
    
    /// 名字
    @IBOutlet weak var nameLabel: UILabel!
    
    
    /// vip皇冠
    @IBOutlet weak var vipImageView: UIImageView!
    
    /// 时间
    @IBOutlet weak var timeLabel: UILabel!
    
    /// 来源
    @IBOutlet weak var sourceLabel: UILabel!
    
    /// vip图标
    @IBOutlet weak var vipIconImageView: UIImageView!
    
    /// 底部工具栏
    @IBOutlet weak var bottomToolBar: WBStatusToolBar!
    
    /// 配图试图
    @IBOutlet weak var picturesView: WBStatusPictureView!
    
    @IBOutlet weak var statusLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
